package com.hymall.controller.wx;

import com.hymall.bean.MarketStorage;
import com.hymall.bean.common.BaseRespVo;
import com.hymall.bean.common.CommonData;
import com.hymall.service.wx.WxStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileNotFoundException;

/**
 * @author: 牟治宇
 * @description 图片上传
 * @date: 2022/7/19 9:37
 */

@RestController
@RequestMapping("/wx/storage")
public class WxStorageUploadController {


    @Autowired
    WxStorageService wxStorageService;


    /**
     * @author 牟治宇
     * @description 图片上传
     * @date 2022/7/19 16:55
     * @param
     * @return com.hymall.bean.common.BaseRespVo
     */
    @PostMapping("upload")
    public BaseRespVo picUpload(MultipartFile file){

        MarketStorage marketStorage = null;
        try {
            marketStorage = wxStorageService.uploadPic(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return BaseRespVo.ok(marketStorage);
    }

}
